package com.htgd.gardenexpo.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.htgd.gardenexpo.dto.GeConTheaterPlanDTO;
import com.htgd.gardenexpo.entity.*;
import com.htgd.gardenexpo.service.IGeConTheaterTimeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;

/**
 * <p>
 * 剧场放映时间设置 前端控制器
 * </p>
 *
 * @author author
 * @since 2024-10-17
 */
@RestController
@RequestMapping("/api/theaterTime")
@Api(tags = "剧场放映时间")
public class GeConTheaterTimeController {

    @Autowired
    private IGeConTheaterTimeService geConTheaterTimeService;

    @PostMapping(value = "/edit")
    @ApiOperation("编辑")
    public CommonResult edit(@RequestBody GeConTheaterTime geConTheaterTime) {
        geConTheaterTime.setId("1");
        geConTheaterTime.setUpdateTime(LocalDateTime.now());
        geConTheaterTimeService.updateById(geConTheaterTime);
        return CommonResult.success("修改成功");
    }

    @GetMapping(value = "/details")
    @ApiOperation("详情")
    public CommonResult<String> details() {
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm");
        GeConTheaterTime geConTheaterTime = geConTheaterTimeService.getById(1);
        String formattedTime = geConTheaterTime.getShowTime().format(formatter);
        return CommonResult.success("查询成功",formattedTime);
    }

}
